package com.seanchenxi.gwt.wordpress.xmlrpc.service;

import java.util.ArrayList;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.seanchenxi.gwt.wordpress.domain.model.Author;
import com.seanchenxi.gwt.wordpress.domain.model.Blog;
import com.seanchenxi.gwt.wordpress.domain.model.Category;
import com.seanchenxi.gwt.wordpress.domain.model.CategoryCreator;
import com.seanchenxi.gwt.wordpress.domain.model.Comment;
import com.seanchenxi.gwt.wordpress.domain.model.CommentCount;
import com.seanchenxi.gwt.wordpress.domain.model.CommentCreator;
import com.seanchenxi.gwt.wordpress.domain.model.CommentEditor;
import com.seanchenxi.gwt.wordpress.domain.model.CommentFinder;
import com.seanchenxi.gwt.wordpress.domain.model.FileData;
import com.seanchenxi.gwt.wordpress.domain.model.Options;
import com.seanchenxi.gwt.wordpress.domain.model.Page;
import com.seanchenxi.gwt.wordpress.domain.model.PageEditor;
import com.seanchenxi.gwt.wordpress.domain.model.PageList;
import com.seanchenxi.gwt.wordpress.domain.model.PageTemplate;
import com.seanchenxi.gwt.wordpress.domain.model.SimpleCategory;
import com.seanchenxi.gwt.wordpress.domain.model.Tag;
import com.seanchenxi.gwt.wordpress.domain.model.WpFile;


/**
 * The Interface WordPressService.
 * 
 * This class is a implementation of the wordpress's XMLRPC API
 * 
 * @author Xi
 */
public interface WordPressServiceAsync {

	/**
	 * Retrieve the blogs of the users.
	 *
	 * @param username the user name
	 * @param password the password
	 * @param callback the callback
	 * @return the user's blogs
	 */
	void getUsersBlogs(String username, String password, AsyncCallback<ArrayList<Blog>> callback);

	/**
	 * Get the page identified by the page id.
	 *
	 * @param blogId the blog id
	 * @param pageId the page id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the page
	 */
	void getPage(int blogId, int pageId, String username, String password, AsyncCallback<Page> callback);

	/**
	 * Get an array of all the pages on a blog.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the pages
	 */
	void getPages(int blogId, String username, String password, AsyncCallback<ArrayList<Page>> callback);

	/**
	 * Create a new page. Similar to MetaWeblogService.newPost().
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param content the content
	 * @param publish the publish
	 * @param callback the callback
	 */
	void newPage(int blogId, String username, String password, PageEditor content,
			boolean publish, AsyncCallback<Integer> callback);

	/**
	 * Removes a page from the blog.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param pageId the page id
	 * @param callback the callback
	 */
	void deletePage(int blogId, String username, String password, int pageId, AsyncCallback<Boolean> callback);

	/**
	 * Make changes to a blog page.
	 *
	 * @param blogId the blog id
	 * @param pageId the page id
	 * @param username the username
	 * @param password the password
	 * @param content the content
	 * @param publish the publish
	 * @param callback the callback
	 */
	void editPage(int blogId, int pageId, String username, String password,
			PageEditor content, boolean publish, AsyncCallback<Boolean> callback);

	/**
	 * Get a list of all the pages on a blog. Just the minimum details, lighter
	 * than the methode getPages(int blogId, String username, String password).
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the page list
	 */
	void getPageList(int blogId, String username, String password, AsyncCallback<ArrayList<PageList>> callback);

	/**
	 * Get a list of users for the blog.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the authors
	 */
	void getAuthors(int blogId, String username, String password, AsyncCallback<ArrayList<Author>> callback);

	/**
	 * Get a list of available categories on a blog.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the categories
	 */
	void getCategories(int blogId, String username, String password, AsyncCallback<ArrayList<Category>> callback);

	/**
	 * Get list of all tags.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the tags
	 */
	void getTags(int blogId, String username, String password, AsyncCallback<ArrayList<Tag>> callback);

	/**
	 * Create a new category.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param categoryCreator the category creator
	 * @param callback the callback
	 */
	void newCategory(int blogId, String username, String password,
			CategoryCreator categoryCreator, AsyncCallback<Integer> callback);

	/**
	 * Delete a category.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param categoryId the category id
	 * @param callback the callback
	 */
	void deleteCategory(int blogId, String username, String password,
			int categoryId, AsyncCallback<Boolean> callback);

	/**
	 * Get a list of categories that start with a given string.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param category the category
	 * @param max_results the max_results
	 * @param callback the callback
	 */
	void suggestCategories(int blogId, String username,
			String password, String category, int max_results, AsyncCallback<ArrayList<SimpleCategory>> callback);

	/**
	 * Upload a file.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param data the data
	 * @param callback the callback
	 */
	void uploadFile(int blogId, String username, String password,
			FileData data, AsyncCallback<WpFile> callback);

	/**
	 * Retrieve comment count for a specific post.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param postId the post id
	 * @param callback the callback
	 * @return the comment count
	 */
	void getCommentCount(int blogId, String username,
			String password, String postId, AsyncCallback<ArrayList<CommentCount>> callback);

	/**
	 * Retrieve post statuses.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the post status list
	 */
	void getPostStatusList(int blogId, String username,
			String password, AsyncCallback<ArrayList<String>> callback);

	/**
	 * Retrieve all of the WordPress supported page statuses.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the page status list
	 */
	void getPageStatusList(int blogId, String username,
			String password, AsyncCallback<ArrayList<String>> callback);

	/**
	 * Retrieve page templates.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the page templates
	 */
	void getPageTemplates(int blogId, String username,
			String password, AsyncCallback<ArrayList<PageTemplate>> callback);

	/**
	 * Retrieve blog options. If passing in a list, search for options listed
	 * within it.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param optionNames the option names
	 * @param callback the callback
	 * @return the options
	 */
	void getOptions(int blogId, String username, String password,
			ArrayList<String> optionNames, AsyncCallback<ArrayList<Options>> callback);

	/**
	 * Update blog options. Returns a list of <b>Options.class</b> showing
	 * updated values.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param options the options
	 * @param callback the callback
	 */
	void setOptions(int blogId, String username, String password,
			ArrayList<Options> options, AsyncCallback<ArrayList<Options>> callback);

	/**
	 * Gets a comment, given it's comment ID. Note that this isn't in 2.6.1, but
	 * is in the HEAD (so should be in anything newer than 2.6.1)
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param commentId the comment id
	 * @param callback the callback
	 * @return the comment
	 */
	void getComment(int blogId, String username, String password,
			int commentId, AsyncCallback<Comment> callback);

	/**
	 * Gets a list of comments for a given post.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param commentFinder the comment finder
	 * @param callback the callback
	 * @return the comments
	 */
	void getComments(int blogId, String username, String password,
			CommentFinder commentFinder, AsyncCallback<ArrayList<Comment>> callback);

	/**
	 * Remove comment.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param commentId the comment id
	 * @param callback the callback
	 */
	void deleteComment(int blogId, String username, String password,
			int commentId, AsyncCallback<Boolean> callback);

	/**
	 * Edit comment.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param commentId the comment id
	 * @param comment the comment
	 * @param callback the callback
	 */
	void editComment(int blogId, String username, String password,
			int commentId, CommentEditor commentEditor, AsyncCallback<Boolean> callback);

	/**
	 * Create new comment. If you want to send anonymous comments, leave the
	 * second and third parameter blank and install <a target="_blank"
	 * href="http://www.thepicklingjar.com/code/anonymous-xmlrpc-comments/">a
	 * filter to xmlrpc_allow_anonymous_comments to return true</a>.
	 * 
	 * See this WordPress forum <a
	 * href="http://wordpress.org/support/topic/304306?replies=1#post-1188046"
	 * >post</a> for more details.
	 * 
	 * the new comment id
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param postId the post id
	 * @param comment the comment
	 * @param callback the callback
	 */
	void newComment(int blogId, String username, String password, int postId,
			CommentCreator commentCreator, AsyncCallback<Integer> callback);

	/**
	 * Retrieve all of the comment status.
	 *
	 * @param blogId the blog id
	 * @param username the username
	 * @param password the password
	 * @param callback the callback
	 * @return the comment status list
	 */
	void getCommentStatusList(int blogId, String username,
			String password, AsyncCallback<ArrayList<String>> callback);

}
